//
//  UserInfoDetailTagCell.m
//  Coding_iOS
//
//  Created by Ease on 15/3/18.
//  Copyright (c) 2015年 Coding. All rights reserved.
//

#import "UserInfoDetailTagCell.h"
#import "NSString+Common.m"
@interface UserInfoDetailTagCell (){
    UIView *line;
}
@end

@implementation UserInfoDetailTagCell

-(UILabel *)title{
    if(!_title){
        _title=[[UILabel alloc]init];
    }
    return _title;
}

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self= [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if(self){
        [self initSubView];
    }
    return self;
}

- (void)initSubView{
    [self addSubview:self.title];
    self.title.font=[UIFont systemFontOfSize:16*BIZ];
    self.title.textColor=UIColorFromRGB(0x787878);
    self.title.numberOfLines = 0;
    self.selectionStyle=UITableViewCellSelectionStyleNone;
    line=[[UIView alloc]init];
    line.backgroundColor=[UIColor colorWithRed:0.94 green:0.95 blue:0.95 alpha:1.00];
    [self.contentView addSubview:line];
}

- (void)setTitleContent:(NSString *)title
{
    _title.text = title;
    _title.frame=CGRectMake(5.,0 , kScreen_Width -10, [UserInfoDetailTagCell cellHeightWithObj:_title.text ]);
    
    line.frame=CGRectMake(8,CGRectGetMaxY(_title.frame), DEF_SCREEN_WIDTH-8, 1);
 
}

+ (CGFloat)cellHeightWithObj:(NSString *)string{
    CGFloat cellHeight = 44;
    CGFloat mWidth = [UIScreen mainScreen].bounds.size.width - 100;
    cellHeight = [string boundingRectWithSize:CGSizeMake(mWidth,MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin  attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:16*BIZ]} context:nil].size.height;
    if(cellHeight<=44){
        return 44;
    }else{
        return cellHeight;
    }
}

+ (CGFloat)cellContentHeight:(NSString *)contents
{
    return  [UserInfoDetailTagCell cellHeightWithObj:contents];
}

@end
